home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 5.6 KB | 251 lines | [TEXT/ToyS] |
- -- Properties
- property kasPrefName : "Slide Show V1.1"
- property kasPause : 5 -- Time between slides
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
-
- global gasFoldersToDo -- The folders left to process
- global gasShown -- Number gone!
- global gasChecked -- Number checked!
-
- global gasDispIdx
- global gasDispCnt
- global gasDispBox
- global gasDisplays
- global gasLastObjs
-
-
- on run
- pfLoad()
- open gasLastObjs
- end run
-
-
- on open fsObjs
- -- Load prefs, show window
- pfLoad()
- set gasLastObjs to fsObjs
- pfSave()
-
- -- Set up prefix
- set gasShown to 0
- set gasChecked to 0
- set gasShowWind to 0
-
- set displays to the display information
- set gasDispIdx to 1
- set gasDispCnt to the number of items of displays
- set gasDispBox to {}
- set gasDisplays to {}
- repeat with dsp in displays
- set box to the monitor box of dsp
- set wDims to {(item 3 of box) - (item 1 of box), (item 4 of box) - (item 2 of box)}
-
- set dWin to ¬
- display drawing titled ("Akua Sweets - " & (item 1 of box) & ":" & (item 2 of box)) ¬
- located at {item 1 of box, item 2 of box} ¬
- with dimensions wDims
-
- set wBox to {0, 0} & wDims
- set gasDispBox to gasDispBox & {wBox}
-
- -- Back drop
- draw a box into dWin ¬
- inside of wBox ¬
- filling it with the pen
-
- set gasDisplays to gasDisplays & {dWin}
- end repeat
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (basic info for fsObj)
-
- if (system type of myInfo is "fold") then
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- else
- DoOne(fsObj)
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
-
- if (n > 1) then
- set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
- else
- set gasFoldersToDo to {}
- end if
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- pause for 5 with seconds timing -- Let screen wait...
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- repeat with win in gasDisplays
- display drawing win with disposal
- end repeat
-
- pfSave() -- Save window location
- end open
-
-
- on DoOne(fsObj)
- set imageType to the image type in fsObj
- set fname to (catalog name of (basic info for fsObj))
-
- display info gasInfoWind ¬
- message fname ¬
- at line 2
-
- if (imageType is not "") then
- display info gasInfoWind ¬
- message imageType ¬
- at line 3
- -- Get picture
- set imagePic to the image from fsObj
- -- Get its bounds
- set pBox to picture bounds of (the picture info for imagePic)
- -- Center it
- set drawInto to PlaceInCenter(pBox, item gasDispIdx of gasDispBox)
- -- Show new image
- draw a box into (item gasDispIdx of gasDisplays) ¬
- inside of (item gasDispIdx of gasDispBox) ¬
- filling it with the pen ¬
- without recording
- draw a picture into (item gasDispIdx of gasDisplays) ¬
- inside of drawInto ¬
- using data imagePic ¬
- without recording
- -- Go to next display
- set imagePic to 0
- set gasDispIdx to gasDispIdx + 1
- if (gasDispIdx > gasDispCnt) then set gasDispIdx to 1
- -- Wait a sec or two
- pause for kasPause with seconds timing
-
- if (shift key down of (input state)) then ¬
- display dialog "Continue?" default button 1
- else
- display info gasInfoWind ¬
- message ¬
- "Unknown" at line 3
- end if
- end DoOne
-
-
- on GoDeep(foldObj)
- display info gasInfoWind ¬
- message "Path: " & (foldObj as string)
-
- set daddy to foldObj as string
-
- -- Do kinds that match
- set myItems to the entries in foldObj ¬
- whose kinds are a file
-
- set n to the number of items in myItems
-
- display info gasInfoWind ¬
- message "Scanning " & n & " files" at line 5
-
- repeat with i from n to 1 by -1
- set x to random number from 1 to i
- set myItem to item x of myItems
- if (x is 1) then
- if (i is 1) then
- set myItems to {}
- else
- set myItems to items 2 through -1 of myItems
- end if
- else if (x is i) then
- set myItems to items 1 through -2 of myItems
- else
- set myItems to (items 1 through (x - 1) of myItems) & (items (x + 1) through -1 of myItems)
- end if
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do folders
- display info gasInfoWind ¬
- message "Scanning subfolders" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
-
- -- Done
- display info gasInfoWind ¬
- message "…" at line 5
- end GoDeep
-
-
- on PlaceInCenter(src, dst)
- -- Place src in dst w/ scaling
- set sW to (item 3 of src) - (item 1 of src)
- set sH to (item 4 of src) - (item 2 of src)
- set dW to (item 3 of dst) - (item 1 of dst)
- set dH to (item 4 of dst) - (item 2 of dst)
-
- set r to dW / sW
- set rH to dH / sH -- ratios
-
- if (rH < r) then set r to rH
-
- -- Round to a .25 ratio if > 1
- if (r > 1) then ¬
- set r to 0.25 * (round (r * 4))
-
- -- Scale the src
- set sW to round (sW * r)
- set sH to round (sH * r)
- set mW to round ((dW - sW) / 2)
- set mH to round ((dH - sH) / 2)
-
- -- Center it
- return {mW, mH, mW + sW, mH + sH}
- end PlaceInCenter
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- on error
- set ourPrefs to {{8, 48}, {8, 96}, {}}
- end try
-
- set gasInfoPos to item 1 of ourPrefs
- set gasShowLoc to item 2 of ourPrefs
- set gasLastObjs to item 3 of ourPrefs
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos, {-1, -1}, gasLastObjs} named kasPrefName
- end pfSave
-